<?php
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
$this->title = '订单列表';
$this->params['breadcrumbs'][]='>';
$this->params['breadcrumbs'][] = ['label' => '订单管理', 'url' => ['/admin/order/list']];
$this->params['breadcrumbs'][]='>';
$this->params['breadcrumbs'][] = $this->title;
$questionvalue = Yii::$app->request->get('question');
$statusvalue=Yii::$app->request->get('status');
$adminvalue = Yii::$app->request->get('adminid');
$css=<<<css
.form-group{float: left;margin:0 10px 10px 0;}
.form-group select{height: 30px;}
.post-search{float: left;margin:10px 0px;}
.common-ui{height: 40px;line-height: 40px;background:#169dd9;width: 100%;color:#fff;font-size: 14px;text-indent: 12px;display: block;float: left;margin-bottom: 10px;font-weight:normal;}
css;
$this->registerCss($css);
?>
    <!-- main container -->
        
        <div class="container-fluid">
            <div id="pad-wrapper" class="users-list">
                <div class="row-fluid header">
                    <h3>订单列表</h3>
                    <div class="span10 pull-right">
                        <a href="<?php echo yii\helpers\Url::to(['order/add']) ?>" class="btn-flat success pull-right">
                            <span>&#43;</span>
                            添加新订单
                        </a>
                    </div>
                </div>
                <?php if($bool):?>
                <div class="row-fluid filter-block" style="margin-bottom: 10px;">
                    <div class="pull-right">
                        <a class="btn-flat new-product" href="<?php echo \yii\helpers\Url::to(['order/list','adminid'=>Yii::$app->admin->id]);?>">查看指派给我的订单</a>
                    </div>
                </div>
                <?php endif;?>

                <h3 class="common-ui" >查询</h3>
                <div class="comment-search" style="display: block;">
                    <div class="post-search">
                        <?php
                        $action=Url::to(['order/list']);
                        $form = ActiveForm::begin([
                            'action' => $action,
                            'method' => 'get',
                            'options'=>["class"=>"form-inline"],
                        ]);
                        ?>
                        <div class="form-group">
                            <?php echo Html::label('报修问题:　', null). Html::textInput('question',$questionvalue,['placeholder' => '请输入报修问题']); ?>
                        </div>
                        <div class="form-group">
                            <?php echo Html::label('订单状态:　', null). Html::dropDownList('status',$statusvalue,$status); ?>
                        </div>
                        <div class="form-group">
                            <?php echo Html::label('报修师傅:　', null). Html::dropDownList('adminid',$adminvalue,$adminlist); ?>
                        </div>
                        <div class="form-group">
                            <?php echo Html::submitButton('查询', ['class' => 'btn btn-primary']); ?>
                            <?php echo Html::a('重置',Url::to(['order/list']), ['class' => 'btn btn-default']);?>
                            <?php echo Html::a('我的订单',Url::to(['order/list','adminid'=>Yii::$app->admin->id]), ['class' => 'btn btn-default']);?>
                        </div>
                        <?php ActiveForm::end(); ?>
                    </div>
                </div>

                <h3 class="common-ui" ><?php echo $this->title;?></h3>
                <!-- Users table -->
                <div class="row-fluid table">
                    <table class="table table-hover">
                        <thead>
                        <tr>
                            <th class="span3 sortable">
                                <span class="line"></span>ID
                            </th>
                            <th class="span3 sortable">
                                <span class="line"></span>关联产品名称
                            </th>
                            <th class="span3 sortable">
                                <span class="line"></span>合同编号
                            </th>
                            <th class="span3 sortable">
                                <span class="line"></span>接单时间
                            </th>
                            <th class="span3 sortable">
                                <span class="line"></span>报修问题
                            </th>
                            <th class="span3 sortable">
                                <span class="line"></span>订单状态
                            </th>
                            <th class="span3 sortable">
                                <span class="line"></span>指派师傅
                            </th>
                            <th class="span3 sortable align-right">
                                <span class="line"></span>操作
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                        <!-- row -->
                        <?php foreach($data as $v): ?>
                            <tr class="first">
                                <td>
                                    <?php echo $v['id'] ?>
                                </td>
                                <td>
                                    <?php echo $v['productid'] ?>
                                </td>
                                <td>
                                    <?php echo $v['contractNum'] ?>
                                </td>
                                <td>
                                    <?php echo $v['orderTime'] ?>
                                </td>
                                <td>
                                    <?php echo $v['question'] ?>
                                </td>
                                <td>
                                    <?php echo $v['statusname'] ?>
                                </td>
                                <td>
                                    <?php echo $v['adminname'] ?>
                                </td>
                                <td class="align-right">
                                    <a href="<?php echo yii\helpers\Url::to(['order/mod', 'id' => $v['id']]); ?>">编辑</a>
                                    <?php if($v['status']==1):?>
                                    <a href="<?php echo yii\helpers\Url::to(['order/jiedan', 'id' => $v['id']]); ?>">是否接单</a>
                                    <?php endif;?>
                                    <?php if($v['status']==2):?>
                                        <a href="<?php echo yii\helpers\Url::to(['order/maintain', 'id' => $v['id']]); ?>">维修结束</a>
                                    <?php endif;?>
                                    <?php if($v['status']==3):?>
                                        <a href="<?php echo yii\helpers\Url::to(['order/detail', 'id' => $v['id']]); ?>">查询详情</a>
                                    <?php endif;?>
                                    <a  dataid="<?=$v['id']?>"  class="orderdel">删除</a>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                        </tbody>
                    </table>
                    <?php
                    if (Yii::$app->session->hasFlash('info')) {
                        echo Yii::$app->session->getFlash('info');
                    }
                    ?>
                </div>
                <div class="pagination pull-right">
                    <?php echo yii\widgets\LinkPager::widget([
                        'pagination' => $pager,
                        'prevPageLabel' => '&#8249;',
                        'nextPageLabel' => '&#8250;',
                        ]); ?>
                </div>
                <div class="pagination pull-right">
                    <span>共<?php echo $total;?>条</span>
                    <div class="pagination ui-select" style="margin-right: 10px;">
                        <select name="per-page">
                            <option value="10">10条/页</option>
                            <option value="20">20条/页</option>
                            <option value="50">50条/页</option>
                            <option value="100">100条/页</option>
                            <option value="200">200条/页</option>
                            <option value="300">300条/页</option>
                            <option value="500">500条/页</option>
                        </select>
                    </div>
                </div>
                <!-- end users table -->
            </div>
        </div>
<?php
$jspage=<<<JS
$(":input[name=per-page]").val($pagesize);
$(":input[name=per-page]").change(function() {
    var size=$(':input[name=per-page]').find('option:selected').val();
    window.location.href='$pageurl'+size;
});
JS;
$this->registerJs($jspage);

$this->registerJsFile('/web/js/jquery-1.10.1.js');
$this->registerJsFile('/web/js/layer/layer.js');
$url=\yii\helpers\Url::to(['order/ajaxdel']);
$js=<<<JS
    $(".orderdel").click(function() {
        var id = $(this).attr("dataid");
         var str='是否确认删除该订单?';  
      layer.confirm(str, {
          btn: ['确定','取消'] //按钮
       }, function(){     
          $.post('$url',{"id":id},function(response) {
            if(response==1){
                window.location.reload();
                return false;
            }else{
                layer.alert('删除失败');
                return false;
            }
          });
       }, function(){
          layer.closeAll();
       });
    });
JS;
$this->registerJs($js);

?>
